package com.zjm.principle.lod;

import java.util.List;

/**
 * 违法迪米特法则
 */
public class Demeter01 {
    public static void main(String[] args) {
        printAllEmployeeNames(new Company());
    }

    public static void printAllEmployeeNames(Company company) {
        for (Department department : company.getDepartments()) {
            for (Employee employee : department.getEmployees()) {
                System.out.println(employee.getName());
            }
        }
    }
}

class Company {
    private List<Department> departments;

    public List<Department> getDepartments() {
        return departments;
    }
}

class Department {
    private List<Employee> employees;

    public List<Employee> getEmployees() {
        return employees;
    }
}

class Employee {
    private String name;

    public String getName() {
        return name;
    }
}